<template>
	<view class="">
		<input type="text" v-model="form.account" placeholder="请输入账号"/>
		<input type="text" v-model="form.pwd" placeholder="请输入密码"/>
		<input type="text" v-model="form.code" placeholder="请输入验证码" />
		<image style="width:400rpx" :src="img" mode="widthFix" />
		<button @click="handleLogin">登录</button>
	</view>
</template>

<script>
	import { getImg } from '@/data/apiAccount.js'
	export default {
		data(){
			return {
				img:'',
				form:{
					account: "sxdxwst",
					pwd: "123456",
					key: "82debd8a12b498e765a11a8e51159440",
					code: ""
				}
			}
		},
		onShow(){
			getImg().then(res=>{
				this.form.key = res.key;
				this.img = res.code;
			})
		},
		methods:{
			handleLogin(){
				this.loading()
				this.$store.dispatch('login', this.form).then(()=>{
					return this.$store.dispatch('getUserInfo')
				}).then(()=>{
					this.$router.back()
				})
			}
		}
	}
</script>

<style>
	
</style>